//
//  UIFont+Size.m
//  OMTCoreKit
//
//  Created by 昭荣伊 on 2018/7/27.
//

#import "UIFont+Size.h"
#import <objc/runtime.h>

@implementation UIFont (Size)

+ (void)setOmt_fontName:(NSString *)omt_fontName {
    objc_setAssociatedObject(self, @selector(omt_fontName), omt_fontName, OBJC_ASSOCIATION_COPY);
}

+ (NSString *)omt_fontName {
    return objc_getAssociatedObject(self, @selector(omt_fontName));
}

+ (void)setOmt_boldFontName:(NSString *)omt_boldFontName {
    objc_setAssociatedObject(self, @selector(omt_boldFontName), omt_boldFontName, OBJC_ASSOCIATION_COPY);
}

+ (NSString *)omt_boldFontName {
    return objc_getAssociatedObject(self, @selector(omt_boldFontName));
}

+ (void)setOmt_italicFontName:(NSString *)omt_italicFontName {
    objc_setAssociatedObject(self, @selector(omt_italicFontName), omt_italicFontName, OBJC_ASSOCIATION_COPY);
}

+ (NSString *)omt_italicFontName {
    return objc_getAssociatedObject(self, @selector(omt_italicFontName));
}

+ (instancetype)omt_fontOfSize:(CGFloat)fontSize {
    UIFont *font = nil;
    if ([self omt_fontName]) {
        font = [UIFont fontWithName:[self omt_fontName] size:fontSize];
    }
    if (!font) {
        font = [UIFont systemFontOfSize:fontSize];
    }
    return font;
}

+ (instancetype)omt_boldFontOfSize:(CGFloat)fontSize {
    UIFont *font = nil;
    if ([self omt_boldFontName]) {
        font = [UIFont fontWithName:[self omt_boldFontName] size:fontSize];
    }
    if (!font) {
        font = [UIFont boldSystemFontOfSize:fontSize];
    }
    return font;
}

+ (instancetype)omt_italicFontOfSize:(CGFloat)fontSize {
    UIFont *font = nil;
    if ([self omt_italicFontName]) {
        font = [UIFont fontWithName:[self omt_italicFontName] size:fontSize];
    }
    if (!font) {
        font = [UIFont italicSystemFontOfSize:fontSize];
    }
    return font;
}

@end
